<?php

namespace app\index\controller;

use think\Controller;
use app\api\controller\User;

class BaseController extends Controller
{

    protected  $user;   //存储登陆用户信息
    public function initialize(){
        parent::initialize();
        $this->isLogin();
        $this->assign('user',$this->user);
        $this->assign('alias',explode('.',request()->pathinfo())[0]);
        $this->assign('config',get_config());
        $this->assign('web_info',get_web_info());
    }

    /**
     * 检查用户是否登陆
     * @desc
     * @author 16
     * @date 2018/4/12
     */
    private function isLogin(){
        if($userInfo = User::checkLogin()){
            $this->user = $userInfo;
        }
    }
}
